<?php
@session_start();
?>

<style>
	#calendar {
		max-width: 900px;
		margin: 0 auto;
	}
</style>
<div class="load-span"></div>
	<div id='calendar' style="display:none;"></div>
	 
<div id="data-popup" class="popup">
    <div class="popup-body"><span class="popup-exit"></span>
 
        <div class="popup-content">
            <h2 class="popup-title">ข้อมูลการเรียน</h2>
			<div class="popup-des">
			<img class="pics" src="../pic/bx_loader.gif" width="50" />
			</div>
        </div>
    </div>
</div>
<div class="popup-overlay"></div>
<script>

	$(document).ready(function() {
$.ajax({
url:"teacher_calendar_json.php?temp=<?php echo $_SESSION["id"]?>",
success:function(resp){
$(".load-span").html('<img class="pics imgload" src="../pic/bx_loader.gif"  width="50" />');
setTimeout(function(){ 
				$(".imgload").remove();
			$('#calendar').show();
$('#calendar').fullCalendar({
			header: {
				left: 'prev,next today',
				center: 'title',
				right: 'month,agendaWeek,agendaDay'
			},
			defaultDate: '2015-01-1',
			businessHours: true, // display business hours
			editable: false,
			events:"json/teacher_events.json",
			eventClick: function(calEvent, jsEvent, view) {
		if(calEvent.meet_complete!='Y'){
      //  alert('Event: ' + calEvent.url);
		 $(this).css({"color":"#fffff"});
		
		  popupCal(calEvent.meet,1);
		//$("#h3title").html("บันทึกการสอน");

		}else{
		  popupCal(calEvent.meet,2);
		}
		 return false;

        // change the border color just for fun
     

    }
		});
		}, 2500);
		
	
}
});
	
		
	});
	
$(document).ready(function(){

 
    $(document).keyup(function (e) {
        if (e.keyCode == 27 && $('html').hasClass('overlay')) {
            clearPopup();
        }
    });
 
      
 
});

function popupCal(meet,typep){

        $('html').addClass('overlay');
        var activePopup = "#data-popup";
        $(activePopup).addClass('visible');
		 $('.popup-overlay').click(function () {
        clearPopup();
		});
		$.ajax({
		url:"teacher/preview_meet_data.php?temp="+meet+"&typep="+typep,
			success:function(res){
			$(".popup-des").html(res);
			 $('.popup-exit').click(function () {
				clearPopup();
				});
			}
		});

}
	  
	
	 function clearPopup() {
        $('.popup.visible').addClass('transitioning').removeClass('visible');
        $('html').removeClass('overlay');
 
        setTimeout(function () {
            $('.popup').removeClass('transitioning');
        }, 200);
    }
</script>